/* This file is part of the Pardus Economy Planner.

   The Pardus Economy Planner is free software: you can redistribute it
   and/or modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation, either version 3 of
   the License, or (at your option) any later version.

   The Pardus Economy Planner is distributed in the hope that it
   will be useful, but WITHOUT ANY WARRANTY; without even the implied
   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with the Pardus Economy Planner.  If not, see
   <http://www.gnu.org/licenses/>.
*/

/*
Number
Incremented every time a new AlertWindow is created. This will make sure the names stay unique and won't overlap.
*/
var AlertWindowCount = 0;

/*
Class: AlertWindow
DHTML non-blocking alert window.
*/
var AlertWindow = new Class({
  /*
  Constructor: AlertWindow
  Initializes the AlertWindow.
  */
  initialize: function(content)
  {
    this.window = new UIWindow({
      caption: "Alert",
      content: content,
      name: "Alert" + (AlertWindow++),
      modal: true,
      closeButton: true
    });
  },
  /*
  Function: show
  Shows the alert.
  */
  show: function()
  {
    this.window.show();
    return this;
  },
  /*
  Function: hide
  Hides the alert.
  */
  hide: function()
  {
    this.window.hide();
    return this;
  },
  /*
  Function: set
  Sets the content of the alert.
  Parameters:
  value - the new content
  */
  set: function(value)
  {
    this.content = value;
    this.window.set("content", this.content);
    return this;
  }
});

/*
Function: ShowAlert
Arguments:
content - Content of the alert

Shorthand for "new AlertWindow(content).show();"
*/

var ShowAlert = function(content)
{
  return new AlertWindow(content).show();
}